<template>
    <!-- <ibs-dialog title= "base64编码/解码" :visible.sync= "visible" width= "70%"> -->
        <div class= "form-wrapper ">
            <el-form ref="dataRef" class="form" :model= 'entityData'
            size='small' inline :rules= "rules" v-loading= "loading">
        <el-row>
            <el-col :md='24' :lg='12'>
                <el-form-item label="类型:" prop= "type">
                    <el-radio-group v-model= "entityData.type">
                        <el-radio :label='false'>解码</el-radio>
                        <el-radio :label='true'>编码</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-col>
            <el-col :md='24' :lg='12' class= "flex-container">
                <div class= "btn-container">
                    <el-button class= "save-button" type= "primary" size= "small" :disabled="loading" @click= "execute">执行处理
                    </el-button>
                </div>
            </el-col>
        </el-row>
        <el-row width= "100%">
            <el-col width= "100% ">
                <!-- el-form-item label="待处理的字符串:"这行注释了 width="700px" -->
                <el-form-item label="待处理的字符串:" prop= "oldString"  class= "el-textarea">
                    <el-input v-model= " entityData.oldString" placeholder="请输入" type="textarea" rows="10" class="my-textarea"/>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row width= "100%">
            <el-col width= "100%">
                <el-form-item label="处理后的字符串:" class="el-textarea">
                    <el-input v-model= "entityData.newString" type="textarea" rows="10" class= "my-textarea"/>
                </el-form-item>
            </el-col>
        </el-row>
        </el-form>
        </div>
    <!-- </ibs-dialog> -->
</template>
<script>
//import TablePageMixin from * @/mixins/TablePageMixin';
//import { dynamicQuery } from ' @/ api/queryStatistical';
// import axios from 'axios'
import {transcoding} from '@/api/xmlDetail'
import { ElMessage} from 'element-plus'
export default {
    // mixins: [TablePageMixin],
    data() {
        return{
            visible: false,
            loading: false,
            rules: {
                type: [{required: true, message: '类型不能为空', trigger: 'blur'}],
                oldString: [{required: true, message: '老的字符串不能为空', trigger: 'blur'}]
            },
            entityData: {
                type : false
            },
            tableData: [],
            colunns: [],
            brnoQryFlag: false,
            brnoMap: {}
        };
    },
    methods: {
        open(parama) {
            this. tableData = [];
            this. batchNo = params. batchNo;
            this. visible = true;
        },
    //调后端处理base64
    async execute (params){
        //防止重复操作
        if (this.loading) {
            return
        }
        this.$refs.dataRef.validate(async validate => {
            debugger
            if (validate){
                this.loading = true
                // console. info( "this. $http={}" + this. $http) ;
                // console. info("this. $http.post={}" + this. $http. post);
                // console. info("typeof this. $http.post={}" + typeof this. $http. post);

                /*
                // axios.post('/admin/xml/detail/transcoding', this.entityData, {

                axios.post('http://localhost:8501/admin/xml/detail/transcoding', this.entityData, {
                    params: {
                    }
                }).then(resp => {
                    debugger
                    this.entityData.newString = resp.data
                    this.loading = false;
                }).catch(error => {
                    debugger
                    this. $message.error(error)
                    this.loading = false;
                })
                */

                try {
                    const resp = await transcoding(this.entityData) 
                    if(resp) {
                        ElMessage.success('操作成功')
                    }
                    this.entityData.newString = resp
                }catch(error){
                    ElMessage.error('操作失败：' + error.message);  
                } finally {  
                    this.loading = false;  
                } 
            }
            this.loading = false;
        })
        },
    }
};
</script>
<style lang="scss" scoped>
.detail-table {
margin: 0 0 24px 0;
.btn-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}
.my-textarea {
    width: 900px;
}
.button-row {
    justify-content: flex-end;
}
.flex-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-container{
    margin-left: 400px;
}
.adjust-interest-add {
    padding-bottom: 20px;
    background-color: #FFFFFF;
    .adjust- interest-add_ return {
        margin: 12px 24px;
    }
    hr {
        border: none;
        height: 1px;
        margin: 0;
        background-color: rgba(179, 179, 179, 0.20);
    }
    .adjust-interest-add_form {
        margin: 20px 24px 0;
        padding-top: 24px;
        padding-right: 24px;
        background-color: #F1F7FD;
    }
    hr {
        border: none;
        height: 1px;
        margin: 24px 0 0;
        background-color: rgba(179, 179, 179, 0.20);
    }
    .form- floor_ buttons {
        width: 100%;
        height: 62px; 
        display: flex;
        align-items: center;
        justify-content: flex- end;
        .save- button {
            margin-left: 16px;
            margin-right: 30px;
        }

        }
    }
}
</style>